package com.hdy.net.order;

import com.google.gson.Gson;
import com.hdy.common.version.OrderVersionController;
import com.hdy.net.order.bean.LoginDataRequest;
import com.hdy.net.order.bean.Request;

import okhttp3.RequestBody;

public class DGJOrder extends BaseOrder {

    String version = OrderVersionController.VERSION_FOR_DGJ;

    public DGJOrder() {
        super();
    }

    @Override
    public void login(Request request, NetCallback callback) {
        super.login(request, callback);
        LoginDataRequest loginDataRequest = (LoginDataRequest) request;
        OrderUrl.DGJ_DOMAIN = loginDataRequest.getWaiter().getIp();
        RequestBody body = RequestBody.create(okhttp3.MediaType.parse(MEDIA_TYPE), new Gson().toJson(request));
        StartRetrofit.getInstance().build(OrderUrl.getDGJBaseUrl(), version)
                .login(OrderUrl.getDGJIntentUrl(), body, new OrderSubscriber(callback));
    }

    @Override
    public void getBasicData(Request request, NetCallback callback) {
        super.getBasicData(request, callback);
        RequestBody body = RequestBody.create(okhttp3.MediaType.parse(MEDIA_TYPE), new Gson().toJson(request));
        StartRetrofit.getInstance().build(OrderUrl.getDGJBaseUrl(), version)
                .getBasicData(OrderUrl.getDGJIntentUrl(), body, new OrderSubscriber(callback));
    }

    @Override
    public void startOrder(Request request, NetCallback callback) {
        super.startOrder(request, callback);
        RequestBody body = RequestBody.create(okhttp3.MediaType.parse(MEDIA_TYPE), new Gson().toJson(request));
        StartRetrofit.getInstance().build(OrderUrl.getDGJBaseUrl(), version)
                .getBasicData(OrderUrl.getDGJIntentUrl(), body, new OrderSubscriber(callback));
    }

    @Override
    public void getOrderInfo(Request request, NetCallback callback) {
        super.getOrderInfo(request, callback);
    }
}
